package com.big.common.utils;

import org.springframework.scheduling.support.SimpleTriggerContext;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;


public class DateUtils {



    public static String getDate(){
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = new Date();
        String nowTime = format.format(date);
        return nowTime;
    }

    public static Long msUtils(String statusTime, String endTime) throws ParseException {
        //开始时间
        String status = statusTime;
        //结束时间
        String end = endTime;

        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date statusDate = dateFormat.parse(status);
        Date endDate = dateFormat.parse(end);
        System.out.println((statusDate.getTime()-statusDate.getTime())/1000);
        return (endDate.getTime() - statusDate.getTime())/1000;
    }


    public static Map<String,Object> msUtilsDate(String statusTime, String endTime) throws ParseException {
        Map<String,Object> timeMap=new HashMap<>();
        //开始时间
        String status = statusTime;
        //结束时间
        String end = endTime;
        Map<String,Object>map=new HashMap<>();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date statusDate = dateFormat.parse(status);
        Date endDate = dateFormat.parse(end);
        long LogStatusTime = statusDate.getTime()/1000;
        long LogEndTime = endDate.getTime()/1000;
        System.out.println(LogStatusTime);
        System.out.println(LogEndTime);
        timeMap.put("statusTime",LogStatusTime);
        timeMap.put("endTime",LogEndTime);
        return timeMap;
    }
    /**
     * @param args
     */
    public static void main(String[] args) throws ParseException {
        //开始时间
        String dateStr1 = "2022-06-06 00:00:00";
        //结束时间
        String dateStr2 = "2022-6-07 00:00:00";
        Map<String, Object> map = msUtilsDate(dateStr1, dateStr2);
        System.out.println(map);
    }
}
